import moveRadar from 'assets/js/CesiumFun/CesiumPubFun/modelMove'
import store from '../../../../store'

export default (viewer) => {
    // 通用模型移动移动方法
    moveRadar(viewer);
    // 自定义鼠标事件
    var hanlder = new Cesium.ScreenSpaceEventHandler(viewer.canvas);;
    // 右键查看信息
    hanlder.setInputAction((movement) => {
        var pick = viewer.scene.pick(movement.position);
        if (!Cesium.defined(pick) || pick._batchId == undefined) {// 过滤未被Ceisum定义和不是3DTiles的模型
            return
        }
        if (pick.tileset.asset.extras[0].type != "radar") { // 过滤不是摄像头的模型
            return
        }
        store.commit("changeRadarId", pick.tileset.asset.extras[0].Id);// 记录右键的雷达的id
        store.commit("showRadarUI", true);// 显示相机调整界面
        // 相机控制界面位置
        var ev = window.event;
        var mousePosition = { x: ev.pageX, y: ev.pageY }
        document.querySelector(".controlBox").style.left = mousePosition.x + "px";
        document.querySelector(".controlBox").style.top = mousePosition.y + "px";

        // 显示雷达范围（x1,y1.....）
        var area = store.getters.searchRadar;
        store.commit('addAreaPosition', area.asset.extras[1])
    }, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
}